package cate.game.play.skill.active;

import cate.common.util.XT;
import cate.game.play.buff.Buff;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.effect.SkillEffect;

import java.util.List;

/**
 * 60%驱散目标全部增益状态，每驱散1个BUFF，额外造成等同目标生命上限5%的伤害，对单个单位的伤害不超过自身攻击力的4倍
 */
public class 荣耀裁决AH extends ActiveHandler{

	private int 概率;

	private double 伤害系数;

	private double 最大系数;

	//概率=6000&伤害系数=500&最大系数=4000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		伤害系数 = args.getWDouble("伤害系数", 0d);
		最大系数 = args.getWDouble("最大系数", 0d);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率+= args.getInt("概率", 0);
	}

	@Override
	public void afterSingleEffect(SkillActionCtx action, SkillEffect effect, Fighter target) {
		if(!XT.chance(概率)){
			return;
		}
		List<Buff> buffs = target.buff.tryDispelGood(action);
		if(XT.isBlank(buffs)){
			return;
		}
		double damage = target.attr.total().hpTotal()*伤害系数*buffs.size();
		double max = skill.owner.attr.attTotal()*最大系数;
		damage = Math.min(damage, max);
		target.attr.passiveHurt(action, skill.owner, damage);
	}
}
